home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import com.sun.java.swing.event.ChangeEvent;
- import com.sun.java.swing.event.ChangeListener;
- import com.sun.java.swing.event.EventListenerList;
- import java.io.Serializable;
-
- public class DefaultBoundedRangeModel implements BoundedRangeModel, Serializable {
- protected transient ChangeEvent changeEvent = null;
- protected EventListenerList listenerList = new EventListenerList();
- private int value = 0;
- private int extent = 0;
- private int min = 0;
- private int max = 100;
- private boolean isAdjusting = false;
- static Class class$com$sun$java$swing$event$ChangeListener;
-
- public DefaultBoundedRangeModel() {
- }
-
- public DefaultBoundedRangeModel(int value, int extent, int min, int max) {
- if (max >= min && value >= min && value + extent <= max) {
- this.value = value;
- this.extent = extent;
- this.min = min;
- this.max = max;
- } else {
- throw new IllegalArgumentException("invalid range properties");
- }
- }
-
- public void addChangeListener(ChangeListener l) {
- EventListenerList var10000 = this.listenerList;
- Class var10001 = class$com$sun$java$swing$event$ChangeListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.ChangeListener");
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
-
- class$com$sun$java$swing$event$ChangeListener = var10001;
- }
-
- var10000.add(var10001, l);
- }
-
- protected void fireStateChanged() {
- Object[] listeners = this.listenerList.getListenerList();
-
- for(int i = listeners.length - 2; i >= 0; i -= 2) {
- Object var10000 = listeners[i];
- Class var10001 = class$com$sun$java$swing$event$ChangeListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.ChangeListener");
- } catch (ClassNotFoundException var3) {
- throw new NoClassDefFoundError(((Throwable)var3).getMessage());
- }
-
- class$com$sun$java$swing$event$ChangeListener = var10001;
- }
-
- if (var10000 == var10001) {
- if (this.changeEvent == null) {
- this.changeEvent = new ChangeEvent(this);
- }
-
- ((ChangeListener)listeners[i + 1]).stateChanged(this.changeEvent);
- }
- }
-
- }
-
- public int getExtent() {
- return this.extent;
- }
-
- public int getMaximum() {
- return this.max;
- }
-
- public int getMinimum() {
- return this.min;
- }
-
- public int getValue() {
- return this.value;
- }
-
- public boolean getValueIsAdjusting() {
- return this.isAdjusting;
- }
-
- public void removeChangeListener(ChangeListener l) {
- EventListenerList var10000 = this.listenerList;
- Class var10001 = class$com$sun$java$swing$event$ChangeListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("com.sun.java.swing.event.ChangeListener");
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
-
- class$com$sun$java$swing$event$ChangeListener = var10001;
- }
-
- var10000.remove(var10001, l);
- }
-
- public void setExtent(int n) {
- int newExtent = Math.max(0, n);
- if (this.value + newExtent > this.max) {
- newExtent = this.max - this.value;
- }
-
- this.setRangeProperties(this.value, newExtent, this.min, this.max, this.isAdjusting);
- }
-
- public void setMaximum(int n) {
- int newMin = Math.min(n, this.min);
- int newValue = Math.min(n, this.value);
- int newExtent = Math.min(n - newValue, this.extent);
- this.setRangeProperties(newValue, newExtent, newMin, n, this.isAdjusting);
- }
-
- public void setMinimum(int n) {
- int newMax = Math.max(n, this.max);
- int newValue = Math.max(n, this.value);
- int newExtent = Math.min(newMax - newValue, this.extent);
- this.setRangeProperties(newValue, newExtent, n, newMax, this.isAdjusting);
- }
-
- public void setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean adjusting) {
- if (newMin > newMax) {
- newMin = newMax;
- }
-
- if (newValue > newMax) {
- newMax = newValue;
- }
-
- if (newValue < newMin) {
- newMin = newValue;
- }
-
- if (newExtent + newValue > newMax) {
- newExtent = newMax - newValue;
- }
-
- if (newExtent < 0) {
- newExtent = 0;
- }
-
- boolean isChange = newValue != this.value || newExtent != this.extent || newMin != this.min || newMax != this.max || adjusting != this.isAdjusting;
- if (isChange) {
- this.value = newValue;
- this.extent = newExtent;
- this.min = newMin;
- this.max = newMax;
- this.isAdjusting = adjusting;
- this.fireStateChanged();
- }
-
- }
-
- public void setValue(int n) {
- int newValue = Math.max(n, this.min);
- if (newValue + this.extent > this.max) {
- newValue = this.max - this.extent;
- }
-
- this.setRangeProperties(newValue, this.extent, this.min, this.max, this.isAdjusting);
- }
-
- public void setValueIsAdjusting(boolean b) {
- this.setRangeProperties(this.value, this.extent, this.min, this.max, b);
- }
-
- public String toString() {
- String modelString = "value=" + this.getValue() + ", " + "extent=" + this.getExtent() + ", " + "min=" + this.getMinimum() + ", " + "max=" + this.getMaximum() + ", " + "adj=" + this.getValueIsAdjusting();
- return this.getClass().getName() + "[" + modelString + "]";
- }
- }
-